home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / c / pthd-0.000 / pthd-0 / pthd-0.7 / include / dce / pthread.h < prev   
Encoding:
C/C++ Source or Header  |  1995-08-16  |  9.9 KB  |  364 lines

  1. #ifndef _pthread_
  2. #define _pthread_
  3.  
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #include "typedefs.h"
  8.  
  9. /*
  10.  * --  Forward declare these pointers to structures that will be defined
  11.  *     internally.
  12.  */
  13. typedef int                                pthread_key_t;
  14. typedef struct PTHREAD_HANDLE *            pthread_t;
  15. typedef struct PTHREAD_MUTEX_HANDLE *      pthread_mutex_t;
  16. typedef struct PTHREAD_CONDV_HANDLE *      pthread_cond_t;
  17. typedef struct PTHREAD_ATTR_HANDLE *       pthread_attr_t;
  18. typedef struct PTHREAD_MUTEXATTR_HANDLE *  pthread_mutexattr_t;
  19. typedef struct PTHREAD_CONDATTR_HANDLE *   pthread_condattr_t;
  20.  
  21. /*
  22.  * --   These constants inform clients of the capabilities
  23.  *      of PCthreads
  24.  */
  25. #define _POSIX_THREADS
  26. #define _POSIX_THREAD_ATTR_STACKSIZE
  27. #define _POSIX_THREAD_PRIORITY_SCHEDULING
  28. #define _POSIX_THREAD_PRIO_PROTECT
  29. #define _POSIX_THREAD_PRIO_INHERIT
  30.  
  31. #ifdef _POSIX_THREADS_PROCESS_SHARED
  32. #undef _POSIX_THREADS_PROCESS_SHARED
  33. #endif
  34.  
  35. #define _POSIX_DATAKEYS_MAX PTHREAD_C_MAX_DATAKEYS
  36.  
  37. /*
  38.  * --  These constants are required by POSIX.1c
  39.  */
  40. #define SCHED_FIFO   ((int) SCHED_FCFS_C)
  41. #define SCHED_RR     ((int) SCHED_ROUND_ROBIN_C)
  42. #define SCHED_OTHER  ((int) SCHED_PRIORITY_DECAY_C)
  43.  
  44. #define PRI_FIFO_MIN       PTHREAD_MIN_PRIO_C
  45. #define PRI_FIFO_DEFAULT   PTHREAD_DEFAULT_PRIO_C
  46. #define PRI_FIFO_MAX       PTHREAD_MAX_PRIO_C
  47.  
  48. #define PRI_RR_MIN      PRI_FIFO_MIN
  49. #define PRI_RR_DEFAULT  PRI_FIFO_DEFAULT
  50. #define PRI_RR_MAX      PRI_FIFO_MAX
  51.  
  52. #define PRI_OTHER_MIN      PRI_FIFO_MIN
  53. #define PRI_OTHER_DEFAULT  PRI_FIFO_DEFAULT
  54. #define PRI_OTHER_MAX      PRI_FIFO_MAX
  55.  
  56. #define PTHREAD_INHERIT_SCHED          PTHREAD_USE_ATTRIBUTES_C
  57. #define PTHREAD_DEFAULT_SCHED          PTHREAD_SCHED_INHERIT_C
  58.  
  59. #define PTHREAD_CANCEL_ENABLE          THREAD_CANCEL_ENABLED_C
  60. #define PTHREAD_CANCEL_DISABLE         THREAD_CANCEL_DISABLED_C
  61. #define PTHREAD_CANCEL_DEFERRED        THREAD_CANCEL_DEFERRED_C
  62. #define PTHREAD_CANCEL_ASYNCHRONOUS    THREAD_CANCEL_ASYNC_C
  63. #define PTHREAD_CANCELED               ((void *) -1)
  64.  
  65. #define MUTEX_SCHED_DEFAULT            SCHED_MUTEX_NO_PRIO_INHERIT_C
  66. #define MUTEX_SCHED_INHERIT            SCHED_MUTEX_PRIO_INHERIT_C
  67. #define MUTEX_SCHED_PROTECT            SCHED_MUTEX_PRIO_PROTECT_C
  68.  
  69. #define PTHREAD_CREATE_JOINABLE        PTHREAD_JOINABLE_C
  70. #define PTHREAD_CREATE_DETACHED        PTHREAD_DETACHED_C
  71.  
  72. /*-------------------------------------------------------------------------*
  73.  * --  POSIX .1c API services.                                             *
  74.  *-------------------------------------------------------------------------*/
  75.  
  76. /*
  77.  * This service allows a thread to wait for a specified set of signals
  78.  * to be delivered to the process.  Upon delivery of any one of the set
  79.  * of signals, the thread returns from this function with the value of
  80.  * the delivered signal.
  81.  */
  82. extern int
  83. sigwait( sigset_t sigset );
  84.  
  85.  
  86. /*
  87.  * Client applications should use pthread_sigmask() instead of sigprocmask().
  88.  * In fact, all occurrences of sigprocmask are redefined to pthread_sigmask().
  89.  */
  90. extern int
  91. pthread_sigmask( int how, const sigset_t *new, sigset_t *prev );
  92.  
  93.  
  94. /*
  95.  * This routine sends a signal to a specified thread.  Any signal defined to
  96.  * stop, continue, or terminate will be applied to all threads in the
  97.  * process, i.e., the effect will be process-wide.  For example, sending 
  98.  * SIGTERM to *any* thread terminates *all* threads in the process - Even 
  99.  * though it may be handled by the thread to which it was sent.
  100.  *
  101.  * The pthread_kill() service is NOT implemented in this release.
  102.  * Calling pthread_kill() returns ENOSYS.
  103.  */
  104. extern int
  105. pthread_kill( pthread_t handle, int sig );
  106.  
  107.  
  108. extern int  
  109. pthread_create( pthread_t      *handle,
  110.                 pthread_attr_t *th_attr,
  111.                 void *         (*th_proc)(void *),
  112.                 void *         th_proc_arg );
  113. extern int  
  114. pthread_join( pthread_t handle, void **return_value );
  115.  
  116. extern int  
  117. pthread_detach( pthread_t  handle );
  118.  
  119. extern int
  120. pthread_setschedparam( pthread_t handle, 
  121.                        int policy,
  122.                        const struct sched_param *param );
  123.  
  124. extern int
  125. pthread_getschedparam( pthread_t handle,
  126.                        int *policy,
  127.                        struct sched_param *param );
  128. extern int 
  129. pthread_once( pthread_once_t  *once_control, 
  130.               void (*init_routine)(void));
  131.  
  132. extern pthread_t
  133. pthread_self( void );
  134.  
  135. extern int  
  136. pthread_cancel( pthread_t th_h );
  137.  
  138. extern void  
  139. pthread_testcancel( void );
  140.  
  141. extern int
  142. pthread_key_create( pthread_key_t *key, void (*destructor)(void *) );
  143.  
  144. extern int
  145. pthread_getspecific( pthread_key_t key, void **value );
  146.  
  147. extern int
  148. pthread_setspecific( pthread_key_t key, void *value );
  149.  
  150. /*
  151.  * --  this routine replaces pthread_setcancel().
  152.  */
  153. extern int  
  154. pthread_setcancelstate( int new_state, int *prev_state );
  155.  
  156. /*
  157.  * --  This routine replaces pthread_setasynccancel()
  158.  */
  159. extern int 
  160. pthread_setcanceltype( int new_type, int *old_type );
  161.  
  162. extern void  
  163. pthread_yield( void  *arg );
  164.  
  165. extern void
  166. pthread_cleanup_push( void (*cleanup_routine)(void *), void *arg );
  167.  
  168. extern void
  169. pthread_cleanup_pop( int execute );
  170.  
  171. extern void
  172. sched_yield( void );
  173.  
  174. extern int
  175. pthread_equal( pthread_t th1_handle, pthread_t th2_handle );
  176.  
  177. extern void  
  178. pthread_exit( void *exit_value );
  179.  
  180. extern int  
  181. pthread_mutex_init( pthread_mutex_t  *handle, 
  182.                     pthread_mutexattr_t  *mu_attr_h );
  183.  
  184. extern int  
  185. pthread_mutex_destroy( pthread_mutex_t  *handle );
  186.  
  187. extern int  
  188. pthread_mutex_lock( pthread_mutex_t  *handle );
  189.  
  190. extern int  
  191. pthread_mutex_unlock( pthread_mutex_t  *handle );
  192.  
  193. extern int  
  194. pthread_mutex_trylock( pthread_mutex_t  *mu_h );
  195.  
  196. extern int 
  197. pthread_mutex_getprio_ceiling( pthread_mutex_t mu_h );
  198.  
  199. extern int 
  200. pthread_mutex_setprio_ceiling( pthread_mutex_t  *mu_h, int prio_ceiling );
  201.  
  202. extern int  
  203. pthread_cond_init( pthread_cond_t  *handle, pthread_condattr_t  *cv_attr_h );
  204.  
  205. extern int  
  206. pthread_cond_destroy( pthread_cond_t  *handle );
  207.  
  208. extern int  
  209. pthread_cond_wait( pthread_cond_t  *cv_h,  pthread_mutex_t *mu_h );
  210.  
  211. extern int  
  212. pthread_cond_signal( pthread_cond_t  *handle );
  213.  
  214. extern int
  215. pthread_cond_broadcast( pthread_cond_t *handle );
  216.  
  217. extern int  
  218. pthread_cond_timedwait( pthread_cond_t  *cv_h, 
  219.                         pthread_mutex_t  *mu_h, 
  220.                         const struct timespec *abstime );
  221.  
  222. extern int  
  223. pthread_attr_init( pthread_attr_t *handle );
  224.  
  225. extern int  
  226. pthread_attr_destroy( pthread_attr_t *handle );
  227.  
  228. extern int 
  229. pthread_attr_setdetachstate( pthread_attr_t  *handle,
  230.                              int  detached_state );
  231. extern int 
  232. pthread_attr_getdetachstate( pthread_attr_t  *handle,
  233.                              int *detached_state );
  234.  
  235. extern int  
  236. pthread_attr_setstacksize( pthread_attr_t  *handle, size_t stack_size );
  237.  
  238. extern int  
  239. pthread_attr_getstacksize( pthread_attr_t  *handle, size_t  *stack_size );
  240.  
  241. extern int  
  242. pthread_attr_setinheritsched( pthread_attr_t  *handle, int inherit_sched );
  243.  
  244. extern int  
  245. pthread_attr_getinheritsched( pthread_attr_t *handle, int *inherit_sched );
  246.  
  247. extern int  
  248. pthread_attr_setschedpolicy( pthread_attr_t  *handle, int sched_policy );
  249.  
  250. extern int
  251. pthread_attr_getschedpolicy( pthread_attr_t *handle, int *sched_policy );
  252.  
  253. /*
  254.  * --  The xxxschedparam() routines replace the get/setscheduler() and
  255.  *     get/setprio() routines.
  256.  */
  257. extern int  
  258. pthread_attr_getschedparam( pthread_attr_t *handle,
  259.                             struct sched_param *sched_param );
  260.  
  261. extern int  
  262. pthread_attr_setschedparam( pthread_attr_t  *handle, 
  263.                             const struct sched_param *sched_param );
  264.  
  265. extern int
  266. pthread_attr_getschedpriority( pthread_attr_t *handle, int *sched_priority );
  267.  
  268. extern int  
  269. pthread_mutexattr_init( pthread_mutexattr_t  *handle );
  270.  
  271. extern int  
  272. pthread_mutexattr_destroy( pthread_mutexattr_t  *handle );
  273.  
  274. extern int  
  275. pthread_mutexattr_setprotocol(pthread_mutexattr_t  *handle, 
  276.                               pthread_protocol_t protocol );
  277.  
  278. extern int
  279. pthread_mutexattr_getprotocol( pthread_mutexattr_t *handle,
  280.                               pthread_protocol_t *protocol );
  281.  
  282. extern int
  283. pthread_mutexattr_getprio_ceiling( pthread_mutexattr_t *handle,
  284.                                    int *prio_ceiling );
  285.  
  286. extern int 
  287. pthread_mutexattr_setprio_ceiling( pthread_mutexattr_t  *handle,
  288.                                    int prio_ceiling );
  289.  
  290. extern int  
  291. pthread_condattr_init( pthread_condattr_t  *handle );
  292.  
  293. extern int  
  294. pthread_condattr_destroy( pthread_condattr_t  *handle );
  295.  
  296. /*
  297.  * --  Utility functions (non-portable)
  298.  */
  299. extern int
  300. pthread_get_expiration_np( const struct timespec *delta,
  301.                            struct timespec *abstime );
  302.  
  303. extern int
  304. pthread_delay_np( const struct timespec *interval );
  305.  
  306. extern int
  307. pthread_get_ctxsw_counts_np( pthread_t handle,
  308.                              unsigned long *total_count,
  309.                              unsigned long *async_count );
  310.  
  311. extern int
  312. pthread_checkstack_np( pthread_t handle, size_t *bytes );
  313.  
  314. extern int
  315. pthread_errno_np( pthread_t *handle, int *err );
  316.  
  317. extern int
  318. pthread_cond_getwaiters_np( pthread_cond_t handle,
  319.                             unsigned int *waiting_threads );
  320.  
  321. extern int
  322. pthread_mutex_getblocked_np( pthread_mutex_t handle,
  323.                              unsigned int *blocked_threads );
  324.  
  325. extern int
  326. pthread_getprio_np( pthread_t handle, int *current_prio );
  327.  
  328. extern int
  329. pthread_setprio_np( pthread_t handle, int new_priority );
  330.  
  331. extern int
  332. pthread_lock_global_np( void );
  333.  
  334. extern int
  335. pthread_unlock_global_np( void );
  336.  
  337. extern int
  338. system_get_state( unsigned long *intr_count,
  339.                   unsigned long *ctxsw_count,
  340.                   unsigned long *async_preemptions,
  341.                   unsigned long *elapsed_time,
  342.                   int *active_priority );
  343.  
  344. /*
  345.  * This service behaves in all respects like sigaction.
  346.  */
  347. extern int
  348. pthread_sigaction_np( int signal,
  349.                       const struct sigaction *new_action,
  350.                       struct sigaction *prev_action );
  351.  
  352. #undef sigprocmask
  353. #define sigprocmask pthread_sigmask
  354.  
  355.  
  356. #ifdef _DCE_COMPAT_
  357. #include <pthread_dce.h>
  358. #endif
  359.  
  360. #ifdef __cplusplus
  361. }
  362. #endif
  363. #endif
  364.